package cn.edu.ctbu.dp07.service.impl;

import cn.edu.ctbu.dp07.dao.CourseDao;
import cn.edu.ctbu.dp07.entity.Course;
import cn.edu.ctbu.dp07.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseDao courseDao;
    
    @Override
    public List<Course> findAll() {
        return courseDao.findAll();
    }
    
    @Override
    public Course findById(Integer id) {
        return courseDao.findById(id).orElse(null);
    }
    
    @Override
    public Course findByCourseNo(String courseNo) {
        return courseDao.findByCourseNo(courseNo);
    }
    
    @Override
    public Iterable<Course> findByCourseNameContaining(String courseName) {
        return courseDao.findByCourseNameContaining(courseName);
    }
    
    @Override
    public Iterable<Course> findBySemester(String semester) {
        return courseDao.findBySemester(semester);
    }
    
    @Override
    public Course save(Course course) {
        return courseDao.save(course);
    }
    
    @Override
    public void deleteById(Integer id) {
        courseDao.deleteById(id);
    }
} 